import apiClient, { wrapApiCall } from './api';
import type {
  SystemInfo,
} from '../types/api';

// 系统管理API服务
export const systemService = {
  // 获取系统信息
  getSystemInfo: async (connectionId: string): Promise<SystemInfo> => {
    const response = await wrapApiCall<SystemInfo>(apiClient.get('/system/info', {
      params: { connection: connectionId }
    }));
    return response;
  },

  // 获取libvirt版本信息
  getLibvirtVersion: async (connectionId: string): Promise<{ libvirt_version: string }> => {
    const response = await wrapApiCall<{ libvirt_version: string }>(apiClient.get('/system/libvirt-version', {
      params: { connectionId }
    }));
    return response;
  },

  // 获取节点信息
  getNodeInfo: async (connectionId: string): Promise<any> => {
    const response = await wrapApiCall<any>(apiClient.get('/system/node-info', {
      params: { connection: connectionId }
    }));
    return response;
  },

  // 获取主机能力信息
  getHostCapabilities: async (connectionId: string): Promise<string> => {
    const response = await apiClient.get('/system/capabilities', {
      params: { connection: connectionId },
      responseType: 'text',
    });
    
    return response.data;
  }
};

export default systemService;